$(document).ready(function(){

   $.ajax({
      url: "/SpringbootDemo/userInfo",
      data: {},
      type: "POST",
      dataType: "json",
      success: function(data) {
         $("#username").text(data.username)
      }
   });

   $("#logoutBtn").click(function(){
      $.ajax({
         url: "/SpringbootDemo/logout",
         data: {},
         type: "POST",
         dataType: "json",
         success: function(data) {
            $("#username").text(data.username)
            // data = jQuery.parseJSON(data);  //dataType指明了返回数据为json类型，故不需要再反序列化
         }
      });
   });
});